package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCRoutineServiceItem;
import com.shrct.businessprocess.customerservice.RCRoutineServicePlan;
import com.shrct.businessprocess.customerservice.RCRoutineServicePlanItem;
import com.shrct.businessprocess.customerservice.impl.RCRoutineServiceItemImpl;
import com.shrct.businessprocess.customerservice.impl.RCRoutineServicePlanImpl;
import com.shrct.businessprocess.customerservice.proxy.RCRoutineServicePlanItemProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCROUTINESERVICEPLANITEM_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcroutineserviceplanitem")
public class RCRoutineServicePlanItemImpl extends BaseModelObject implements RCRoutineServicePlanItem {
  public RCRoutineServicePlanItemImpl() {
    super();
  }
  
  public RCRoutineServicePlanItemImpl(final RCRoutineServicePlan plan) {
    super();
    this.plan = plan;
  }
  
  @JoinColumn(name = "remender_id")
  @ManyToOne(targetEntity = RCRoutineServiceItemImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCRoutineServiceItem remender;
  
  public RCRoutineServiceItem getRemender() {
    return this.remender;
  }
  
  public RCRoutineServicePlanItem setRemender(final RCRoutineServiceItem remender) {
    this.remender = remender;
    return this;			
    
  }
  
  @JoinColumn(name = "plan_id")
  @ManyToOne(targetEntity = RCRoutineServicePlanImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCRoutineServicePlan plan;
  
  public RCRoutineServicePlan getPlan() {
    return this.plan;
  }
  
  public RCRoutineServicePlanItem setPlan(final RCRoutineServicePlan plan) {
    this.plan = plan;
    return this;			
    
  }
  
  public static RCRoutineServicePlanItem create(final RCRoutineServicePlan plan, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.customerservice.RCRoutineServicePlanItem rCRoutineServicePlanItem = new com.shrct.businessprocess.customerservice.impl.RCRoutineServicePlanItemImpl(
    	plan
    );
    objectFactory.create(rCRoutineServicePlanItem);
    return rCRoutineServicePlanItem;			
    
  }
  
  public static RCRoutineServicePlanItem createRCRoutineServicePlanItemImpl(final RCRoutineServicePlan plan, final IObjectFactory objectFactory, final Procedure1<RCRoutineServicePlanItem> init) {
    com.shrct.businessprocess.customerservice.RCRoutineServicePlanItem rCRoutineServicePlanItem = new com.shrct.businessprocess.customerservice.impl.RCRoutineServicePlanItemImpl(
    	plan
    );
    objectFactory.create(rCRoutineServicePlanItem);
    init.apply(rCRoutineServicePlanItem);
    
    return rCRoutineServicePlanItem;			
    
  }
  
  public RCRoutineServicePlanItemProxy toProxy() {
    com.shrct.businessprocess.customerservice.proxy.RCRoutineServicePlanItemProxy proxy = new com.shrct.businessprocess.customerservice.proxy.RCRoutineServicePlanItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
